import store from '@/store'
import router from '@/router'
const widthList = ['/login', '/404']
router.beforeEach((to, from, next) => {
  const token = store.state.user.userList.token
  if (token) {
    // if (!store.getters.userId) {
    //   store.dispatch('user/getUserInfoAcion')
    // }
    if (to.path === '/login') {
      next('/')
    } else {
      next()
    }
  } else {
    if (widthList.includes(to.path)) {
      next()
    } else {
      next('/login')
    }
  }
})
